package com.wowkids.service.impl;

import com.wowkids.dao.UserPo;
import com.wowkids.mapper.UserMapper;
import com.wowkids.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public List<UserPo> getAll() {
        return userMapper.query(new UserPo());
    }

    @Override
    public String login(UserPo user) {
        List<UserPo> userList = userMapper.queryByUserNameAndPassword(user.getName(), user.getPasswd());
        if (CollectionUtils.isEmpty(userList)) {
            return "账户名或密码错误";
        }
        if (userList.size() > 1) {
            return user.getName() + "数据错误,请通知管理员处理";
        }
        return null;
    }


}
